﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
//using AssemblyCSharp;
using System.Text;
using System.Security.Cryptography;
using System;
using System.Data;  
using MySql.Data;
using MySql.Data.MySqlClient;  
using System.Runtime.InteropServices;


public class BindProductInfo : MonoBehaviour 
{
    public Text tipInfo;
    public InputField inputProductId;
    public InputField inputNumber;
    public InputField inputName;
	public InputField inputPhone;
    public InputField inputCompany;
    public InputField inputAddress;
    public GameObject userInfoPlane;
    public string s1;
    public string s2;
    public string s3;
    public string s4;
    public string s5;
    public string s6;
    public string s7;
    public string s8;
    public string s9;
    public string s10;
    public string s11;
    public string s12;
    public string s13;
    public string s14;
    public string s15;
    public string s16;
    public int n1;
    public int n2;
    DataSet ds;

    void Start()
	{
        userInfoPlane.SetActive(false);
	}

    void GetData()
    {
        //ds = SqlTool._instance.ExistOrNot(s2 + inputProductId.text + s3 + inputNumber.text + s4);
    }

    void GetData2()
    {
        //SqlTool._instance.UpdateInto(s8, new string[] { s9, s10, s11, s12, s13 }, new string[] { inputName.text, inputPhone.text, inputCompany.text, inputAddress.text, SellerInfo.sellername }, s14, inputProductId.text);
    }

    void ResetInput()
    {
        inputName.text = "";
        inputPhone.text = "";
        inputCompany.text = "";
        inputAddress.text = "";
        userInfoPlane.SetActive(false);
    }

    void ShowTip(string ss)
    {
        tipInfo.text = ss;
    }

    public void CheckProductId()
    {
        if (inputProductId.text != "" && inputNumber.text != "")
        {
            ShowTip(s1);
            GetData();
            if (ds.Tables[0].Rows.Count > n1)
            {
                ShowTip(s5);
                userInfoPlane.SetActive(true);
                inputNumber.text = "";
            }
            else
            {
                ShowTip(s6);
            }
        }
        else
        {
            ShowTip(s7);
        }
    } 
    
    public void BindProductId()
    {
        if (inputName.text != "" && inputPhone.text.Length == n2)
        {
            GetData2();
            ShowTip(s15);
            ResetInput();
        }
        else
        {
            ShowTip(s16);
        }
     }
}
